home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0004_A simple Star Field.pas < prev    next >
Pascal/Delphi Source File  |  1993-07-16  |  1KB  |  80 lines

  1.  
  2. program stars;
  3.  
  4. const
  5.   maxstars = 200;
  6.  
  7. var star  : array[0..maxstars] of word;
  8.     speed : array[0..maxstars] of byte;
  9.     i     : word;
  10.  
  11. procedure create;
  12. begin
  13.   for i := 0 to maxstars do
  14.     begin
  15.     star[i] := random(320) + random(200) * 320;
  16.     speed[i] := random(3) + 1;
  17.     if mem[$a000:star[i]] = 0 then
  18.       mem[$a000:star[i]] := 100;
  19.   end;
  20. end;
  21.  
  22. Procedure moveit; assembler;
  23. asm
  24.      xor   bp,bp
  25.      mov   ax,0a000h
  26.      mov   es,ax
  27.      lea   bx,star
  28.      lea   si,speed
  29.      mov   cx,320
  30.  
  31. @l1: mov   di,[bx]
  32.      mov   al,es:[di]
  33.      cmp   al,100
  34.      jne   @j1
  35.      xor   al,al
  36.      stosb
  37. @j1: mov   al,[si]
  38.      xor   ah,ah
  39.      add   [bx],ax
  40.      mov   ax,bx
  41.      xor   dx,dx
  42.      div   cx
  43.      mul   cx
  44.      mov   dx,bx
  45.      sub   dx,ax
  46.      cmp   dx,319
  47.      jle   @j3
  48.      sub   [bx],cx
  49. @j3: mov   di,[bx]
  50.      mov   al,es:[di]
  51.      or    al,al
  52.      jnz   @j2
  53.      mov   al,100
  54.      stosb
  55. @j2: add   bx,2
  56.      inc   si
  57.      inc   bp
  58.      cmp   bp,maxstars
  59.      jle   @l1
  60. end;
  61.  
  62. begin
  63.   asm
  64.     mov   ax,13h
  65.     int   10h
  66.     call  create
  67. @l1:
  68.     mov   dx,3dah
  69. @r1:
  70.     in    al,dx
  71.     test  al,8
  72.     je    @r1
  73.     call moveit
  74.     in   al,60h
  75.     cmp  al,1
  76.     jne  @l1;
  77.   end;
  78. end.
  79.  
  80.